﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.DS
{
    public static partial class status
    {
        public static dynamic cmpCode(string sid,double similarityDegree)
        {
            var sql = new Sql.SqlDataContext();
            var preSolve = sql.DSSolve.FirstOrDefault(row => row.sid == sid && Math.Abs(row.similarityDegree - similarityDegree) < 0.000001);
            if(preSolve == null)
                return new{
                    success = false,
                    msg = "找不到preSolve"
                };
            var preStatus = sql.DSStatus.FirstOrDefault(row => row.rid == preSolve.bestRid);
            if (preStatus == null)
                return new
                {
                    success = false,
                    msg = "找不到preStatus"
                };
            var preCode = preStatus.code;
            var copyStatus = sql.DSStatus.FirstOrDefault(row => row.rid == preSolve.similarityRid);
            if (copyStatus == null)
                return new
                {
                    success = false,
                    msg = "找不到copyStatus"
                };
            var copyCode = copyStatus.code;
            return new
            {
                success = true,
                preCode,
                copyCode
            };

        }
    }
}
